package com.wang.commons.utils;


import com.wang.commons.exception.DiyException;
import com.wang.commons.pojo.StatusCode;
import org.springframework.validation.BindingResult;

public class ValidUtil {
    public static void  validate(BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            bindingResult.getFieldErrors().forEach(fieldError -> {
                throw new DiyException(StatusCode.NORMALERROR.getCode(), fieldError.getDefaultMessage());
            });
        }
    }
}




